package com.example.myapplication3.audio.bean;

import android.net.Uri;

public class AudioItem {
    private long id;
    private String title;
    private String artist;
    private String album;
    private String path;
    private Uri uri;
    private long size;
    private long duration;
    private long dateAdded;
    private long dateModified;
    private String mimeType;

    public AudioItem(long id, String title, String artist, String album, String path, Uri uri,
                     long size, long duration, long dateAdded, long dateModified, String mimeType) {
        this.id = id;
        this.title = title;
        this.artist = artist;
        this.album = album;
        this.path = path;
        this.uri = uri;
        this.size = size;
        this.duration = duration;
        this.dateAdded = dateAdded;
        this.dateModified = dateModified;
        this.mimeType = mimeType;
    }

    // Getters
    public long getId() { return id; }
    public String getTitle() { return title; }
    public String getArtist() { return artist; }
    public String getAlbum() { return album; }
    public String getPath() { return path; }
    public Uri getUri() { return uri; }
    public long getSize() { return size; }
    public long getDuration() { return duration; }
    public long getDateAdded() { return dateAdded; }
    public long getDateModified() { return dateModified; }
    public String getMimeType() { return mimeType; }

    public String getFormattedSize() {
        if (size <= 0) return "0 B";
        final String[] units = new String[]{"B", "KB", "MB", "GB", "TB"};
        int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
        return String.format("%.1f %s", size / Math.pow(1024, digitGroups), units[digitGroups]);
    }

    public String getFormattedDate() {
        return android.text.format.DateFormat.format("yyyy-MM-dd HH:mm", dateAdded * 1000).toString();
    }

    public String getFormattedDuration() {
        long seconds = duration / 1000;
        long minutes = seconds / 60;
        seconds = seconds % 60;
        return String.format("%02d:%02d", minutes, seconds);
    }
}